import request from '../utils/request';

function Request(url,data,method = 'post') {
    return request({ url:'/' + url, method:method, data:data});
}

const API = {
    /**
     * 登录接口
     * @param {"account":"123456","password":"123456"}
     * @returns {code:1账号不能为空 | 密码不能为空，2已登录，3账号密码错误，200成功}
     */
    // login(data){
    //     return Request('/user/login',data);
    // },
}

export default{
    install(Vue,Options = {}){
        //在这里写插件需要实现的功能
        Vue.prototype.$api = API
    }
}

export function login(data) {
    return request({
        url: '/user/login',//接口url
        method: 'POST',
        data
    })
}

export function register(data) {
    return request({
        url: '/user/register',//接口url
        method: 'POST',
        data
    })
}

export function logout() {
    return request({
        url: '/user/logout',//接口url
        method: 'POST',
    })
}

export function getLoginUser() {
    return request({
        url: '/user/get/login',//接口url
        method: 'GET',
    })
}

export function getUserById(params) {
    return request({
        url: '/user/get',//接口url
        method: 'GET',
        params
    })
}


export function getUserList(params) {
    return request({
        url: '/user/list/page',//接口url
        method: 'GET',
        params
    })
}

export function getQuestionList(params) {
    return request({
        url: '/question/list/page',//接口url
        method: 'GET',
        params
    })
}


export function listUserQuestionByPage(params) {
    return request({
        url: '/user_question/list/page',//接口url
        method: 'GET',
        params
    })
}

export function getQuestionByIds(data) {
    return request({
        url: '/question/getByIds',//接口url
        method: 'POST',
        data
    })
}

// 用户新做了一道题
export function addUserQuestion(data) {
    return request({
        url: '/user_question/add',//接口url
        method: 'POST',
        data
    })
}

export function getAllQuestionList(params) {
    return request({
        url: '/question/list',//接口url
        method: 'GET',
        params
    })
}

export function getAllUser(params) {
    return request({
        url: '/user/list',//接口url
        method: 'GET',
        params
    })
}

export function getAllQuestion(params) {
    return request({
        url: '/question/list',//接口url
        method: 'GET',
        params
    })
}

export function deleteUser(data) {
    return request({
        url: '/user/delete',//接口url
        method: 'POST',
        data
    })
}

export function deleteQuestion(data) {
    return request({
        url: '/question/delete',//接口url
        method: 'POST',
        data
    })
}

export function addUser(data) {
    return request({
        url: '/user/add',//接口url
        method: 'POST',
        data
    })
}

export function addQuestion(data) {
    return request({
        url: '/question/add',//接口url
        method: 'POST',
        data
    })
}

export function updateUser(data) {
    return request({
        url: '/user/update',//接口url
        method: 'POST',
        data
    })
}

export function updateQuestion(data) {
    return request({
        url: '/question/update',//接口url
        method: 'POST',
        data
    })
}

export function addUserBatch(data) {
    return request({
        url: '/user/add/batch',//接口url
        method: 'POST',
        data
    })
}

export function genChartByAiAsync(data) {
    return request({
        contentType: false,
        headers: { 'Content-Type': 'multipart/form-data'},
        url: '/chart/gen/async',//接口url
        method: 'POST',
        data
    })
}

export function getChartById(params) {
    return request({
        url: '/chart/get',//接口url
        method: 'GET',
        params
    })
}

export function addQuestionBatch(data) {
    return request({
        url: '/question/add/batch',//接口url
        method: 'POST',
        data
    })
}

//竞赛增删改查api
export function addContest(data) {
    return request({
        url: '/contest/add',//接口url
        method: 'POST',
        data
    })
}

export function deleteContest(data) {
    return request({
        url: '/contest/delete',//接口url
        method: 'POST',
        data
    })
}

export function updateContest(data) {
    return request({
        url: '/contest/update',//接口url
        method: 'POST',
        data
    })
}

export function getContestList(params) {
    return request({
        url: '/contest/list/page',//接口url
        method: 'GET',
        params
    })
}

export function getAllContestList(params) {
    return request({
        url: '/contest/list',//接口url
        method: 'GET',
        params
    })
}

//学院竞赛api
export function getCollegeContestList(params) {
    return request({
        url: '/college/biz/list/college/contest/page',//接口url
        method: 'GET',
        params
    })
}

export function getCollegeStudentContestList(params) {
    return request({
        url: '/college/biz/list/users/contest/page',//接口url
        method: 'GET',
        params
    })
}

export function deleteCollegeContest(data) {
    return request({
        url: '/college/delete',//接口url
        method: 'POST',
        data
    })
}

export function getAllCollegeContestList(params) {
    return request({
        url: '/college/biz/list/college/contest',//接口url
        method: 'GET',
        params
    })
}

export function getAllCollegeStudentContestList(params) {
    return request({
        url: '/college/biz/list/users/contest',//接口url
        method: 'GET',
        params
    })
}


//公告增删改查api
export function addNotice(data) {
    return request({
        url: '/notice/add',//接口url
        method: 'POST',
        data
    })
}

export function deleteNotice(data) {
    return request({
        url: '/notice/delete',//接口url
        method: 'POST',
        data
    })
}

export function updateNotice(data) {
    return request({
        url: '/notice/update',//接口url
        method: 'POST',
        data
    })
}

export function getNoticeList(params) {
    return request({
        url: '/notice/list/page',//接口url
        method: 'GET',
        params
    })
}

//用户成绩增删改查api
export function addUserScore(data) {
    return request({
        url: '/user_score/add',//接口url
        method: 'POST',
        data
    })
}

export function deleteUserScore(data) {
    return request({
        url: '/user_score/delete',//接口url
        method: 'POST',
        data
    })
}

export function updateUserScore(data) {
    return request({
        url: '/user_score/update',//接口url
        method: 'POST',
        data
    })
}

export function getUserScoreList(params) {
    return request({
        url: '/user_score/list/page',//接口url
        method: 'GET',
        params
    })
}

export function getAllUserScoreList(params) {
    return request({
        url: '/user_score/list',//接口url
        method: 'GET',
        params
    })
}

// export const fetchData = query => {
//     return request({
//         url: './table.json',
//         method: 'get',
//         params: query
//     });
// };
